import { getToken, setToken } from '@/utils/auth';
import { LOGIN } from '../types';

const state = {
  token: getToken() || null
}

const mutations = {
  LOGIN(state, token) {
    state.token = token
  },
}

const actions = {
  login({ commit }, token) {
    commit(LOGIN, token)
    setToken(token)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
